package com.haizhi.crm.common.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 实体类型
 * Created by ch on 2018/2/10.
 */
public enum EntityType {

    PRODUCT("产品", "tv_product", "tv_product" ),
    COUSTOMER("客户", "Company", "Company" ),
    EVENT("事件", "event", "Event" ),
    EVENT_OUTTER("行外事件", "tv_outer_event", "tv_outer_event" ),
    EVENT_INNER("行内动态", "tv_inner_event", "tv_inner_event" ),
    VISIT_RECORD("拜访记录", "tv_visit_record", "tb_visit_record" );


    // 成员变量
    private String name;
    private String value;
    private String mapEsSearch;

    private static Map<String, String> mapAttr = new HashMap<>();

    static {
        for (EntityType item : EntityType.values()) {
            mapAttr.put(item.getMapEsSearch(), item.getValue());
        }
    }

    // 构造方法
    EntityType(String name, String value, String mapEsSearch) {
        this.name = name;
        this.value = value;
        this.mapEsSearch = mapEsSearch;
    }

    // 普通方法
    public static String getName(String value) {
        for (EntityType c : EntityType.values()) {
            if (c.getValue().equals(value)) {
                return c.name;
            }
        }
        return null;
    }

    public static String getMapValue(String mapEsSearch) {
        String resp = mapAttr.get(mapEsSearch);
        if (resp == null) {
            return mapEsSearch;
        }
        return resp;
    }

    public String getMapEsSearch() {
        return this.mapEsSearch;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }


}
